home *** CD-ROM | disk | FTP | other *** search
- /*
- * cardguess.c
- * GLUTExamples
- *
- * Created by ericslos on Fri Jun 22 2001.
- * Copyright (c) 2001 __CompanyName__. All rights reserved.
- *
- */
- #include <stdio.h>
-
- int question( char* q )
- {
- char a[16];
-
- printf( q );
- fflush(stdout);
- fgets(a, 16, stdin);
-
- // printf("'%s'\n", a);
-
- return (strcmp(a,"y \n")==0);
- }
-
- void card_guess()
- {
- int a;
- int isblack, isFirst, bit4, bit3, bit2, bit1;
-
- isblack = question( "are you concentrating? " );
-
- isFirst = question( isblack ? "is your card black? ": "is your card red? ");
-
- if ( isblack )
- bit4 = question(isFirst ? "is your card a CLUB? " : "is your card a SPADE?" );
- else
- bit4 = question(isFirst ? "is your card a DIAMOND? " : "is your card a HEART?" );
-
-
- /* 1 2 3 4 5 6 7 8 9 10 J Q K
- |
- | |
- */
- bit3 = question( bit4 ? "is your card greater than a 6?" : "is your card less than 7?" );
- if ( bit4 ) { // 7..K
- bit2 = question( bit3 ? "is your card greater than 9?" : "is your card less than 10?" );
- if ( bit3 ) { // 10..K
- bit1 = question( bit2 ? "is your card greater than a JACK?" : "is your card less than a QUEEN?" );
- if ( bit2 ) { // Q..K
- question( bit1 ? "is your card a KING?" : "is your card a QUEEN?" );
- } else { // 10..J
- question( bit1 ? "is your card a JACK?" : "is your card a 10?" );
- }
- } else { // 7..9
- bit1 = question( bit2 ? "is your card greater than 8?" : "is your card a 9?" );
- if ( bit2 )
- question( bit1 ? "is your card a 7?" : "is your card an 8?" );
- }
- } else { // A..6
- bit2 = question( bit3 ? "is your card greater than 3?" : "is your card less than 4?" );
- if ( bit3 ) { // 4..6
- bit1 = question( bit2 ? "is your card a 6?" : "is your card less than 6?" );
- if ( !bit2 )
- question( bit1 ? "is your card a 5?" : "is your card an 4?" );
- } else { // A..3
- bit1 = question( bit2 ? "is your card greater than 2?" : "is your card less than a 3?" );
- if (bit2)
- question( "is your card a 3?" );
- else
- question( bit1 ? "is your card a 2?" : "is your card an ACE?" );
- }
- }
-
-
- }
-
- void embarrass_kiki()
- {
- question( "are you tired of card games?");
- question( "do you want to play a different guessing game?");
- question( "do you want Cleo to guess things about you?");
- question( "are you a girl?");
- question( "are you taller than 5 feet?");
- question( "are you shorter than 6 feet?");
- question( "are you just about 5 foot 4 ?");
- question( "so you're shorter than your mom?");
- question( "that's pretty short, huh?");
- question( "do you have a teddy bear?");
- question( "do you like boys?");
- question( "do you know a boy named casey?");
- question( "do you want me to change the subject?");
- // question( "is he cute?");
- question( "did you ever go to Canada?");
- question( "did the border guard ask you if you had something to declare?");
- question( "did you declare 'I love your money?'");
- question( "did you you were getting a computer this week?");
- question( "did you ask your mom if this was true?");
- question( "did she say no?");
- question( "did you believe her?");
- question( "has she ever misled you before?");
- question( "were you silly to believe her this time?");
- question( "are you starting to think that your mother set you up?");
- question( "would you like to get your computer tonight?");
- question( "can you guess what's in the box next to Eric?");
- question( "can you please stop leaving your computer lying around?");
- question( "is this hack over?");
- }